import React, {Component} from 'react'
import {connect} from 'react-redux'
import {loadDataAsync} from '../actionCreator'
import CookBookUi from "./CookBookUI";

const mapState = (state) => {
    return {
        categorys: state.cookbook.categorys
    }
}

const mapDispatch = (dispatch) => {
    return {
        loadCategorys () {
            dispatch(loadDataAsync(dispatch))
        }
    }
}

/**
 * 容器组件
 */
class CookBookContainer extends Component{

    componentDidMount() {
        this.props.loadCategorys()
    }


    render(){
        return (
            <CookBookUi {...this.props}></CookBookUi>
        )
    }
}
export default  connect(mapState,mapDispatch)(CookBookContainer)
